const mysql = require('mysql')
const DB_CONFIG = require('../config');
const co = require('co-mysql');

// 创建数据库链接对象
const db = mysql.createPool({
    host: DB_CONFIG.DB_HOST,
    user: DB_CONFIG.DB_USER,
    password: DB_CONFIG.DB_PASSWORD,
    port: DB_CONFIG.DB_PORT,
    database: DB_CONFIG.DB_NAME
})

// 向外共享db数据库连接对象
module.exports = co(db)